﻿using System.Windows.Controls;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Shapes;

namespace ComicTool.Drawing
{
    public class PathDrawingItem : DrawingItem
    {
        private Path path;
        private readonly string pathInfo;

        public PathDrawingItem(string pathInfo)
        {
            this.pathInfo = pathInfo;
        }

        protected override void Add(Canvas canvas)
        {
            if (path == null)
            {
                path =
                    (Path)
                    XamlReader.Load("<Path xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' Data=\""
                                    + pathInfo + "\"/>");
                path.Fill = new SolidColorBrush(Colors.Red);
            }
            canvas.Children.Add(path);
        }

        protected override void Resize(double width, double height)
        {
            path.Width = width;
            path.Height = height;
        }
    }
}
